package com.example.trafficsystem.controller;

import com.aliyun.oss.OSS;
import com.example.trafficsystem.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/oss")
@CrossOrigin // 允许跨域
public class OssController {
    @Value("${oss.bucket-name}")
    private String bucketName;

    @Value("${oss.endpoint}")
    private String endpoint;

    @Autowired
    private OssService ossService;
    @GetMapping("/list")
    public List<String> listObjects(@RequestParam(required = false,defaultValue = "") String folderName) {
        return ossService.listObjects(folderName);
    }
    @GetMapping("/url")
    public String getUrl(@RequestParam String fileName){
        return ossService.getUrl(fileName);
    }
}
